---
title: "Advanced Dashboarding"
output:
flexdashboard::flex_dashboard:
orientation: row # or column
vertical_layout: fill
social: ["menu"]
source_code: embed
theme:
version: 4
bootswatch: sandstone # a preset CSS style, bootswatch.com
---
```{r setup, include=FALSE}
# In the YAML above, spaces matter!
library(flexdashboard)
library(tidyverse)
library(palmerpenguins)
library(fontawesome) # free icons to use in RMD document
library(plotly) # interactive plots
library(DT) # "DataTable" for interactive tables
data("penguins") # start typing penguins on next line to get the to convert to dataframes
```
Plots {data-navmenu="Pages"}
=======================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------
### Penguin Stats
The number of penguins in the data is `r nrow(penguins)`.
Row
-----------------------------------------------------------------------
### Number of penguins
```{r}
valueBox(nrow(penguins), icon = "fa-linux") # from font awesom
# see fontawesome.com for tons of fonts and icons
```
### Avg body mass
```{r}
avg_mass = round(mean(penguins$body_mass_g, na.rm = T), 1)
gauge(avg_mass,
min(0),
max(penguins$body_mass_g, na.rm = T),
gaugeSectors(success = c(4000, 6300),
warning = c(2000, 3999),
danger = c(0, 1999)))
```
Column {.tabset}
-----------------------------------------------------------------------
### Scatterplot of bill length vs bill depth
```{r}
a <- penguins %>% ggplot(aes(x = bill_length_mm, y = bill_depth_mm, color = species)) +
geom_point()# after "x =" hit tab for variables to show up
ggplotly(a)
# htmlwidgets.org has all kinds of amazing plots to use in dashboards
```
Column {data-width=350}
### Chart B
```{r}
penguins %>% ggplot(aes(x = body_mass_g, y = sex, fill = sex))+
geom_boxplot()
```
### Chart C
```{r}
penguins %>% ggplot(aes(x = flipper_length_mm, fill = species))+
geom_histogram(bins=30) +
facet_wrap(~species)
```
Data {data-navmenu="Pages"}
==============================================================================
```{r}
penguins %>% datatable(extensions = "Buttons",
options = list(dom = "Blfrtip",
buttons = c("copy", "csv", "excel", "pdf", "print"))) # datatable from DT package
# l = length
# p = pagination (ability to go from page 1 to page 2)
# B = add buttons
# default is lfrtip
# datatables.net has all the options to customize your html table
```